<?php
defined('_JEXEC') or die('Restricted access');

  JToolBarHelper::title( JText::_( 'wbDatabase Manager' ), 'generic.png' );
//  JToolBarHelper::preferences('com_wbdatabase');
  JToolBarHelper::deleteList();
  JToolBarHelper::editListX();
  JToolBarHelper::addNewX();

?>

<form action="index.php" method="post" name="adminForm">
  <table>
    <tr>
      <td align="left" width="100%">
        <?php echo JText::_( 'Filter' ); ?>:
        <input type="text" name="search" id="search" value="<?php echo $this->lists['search'];?>" class="text_area" onchange="document.adminForm.submit();" />
        <button onclick="this.form.submit();"><?php echo JText::_( 'Go' ); ?></button>
        <button onclick="document.getElementById('search').value='';this.form.getElementById('filter_state').value='';this.form.submit();"><?php echo JText::_( 'Reset' ); ?></button>
      </td>
    </tr>
  </table>
  <div id="editcell">
    <table class="adminlist">
      <thead>
        <tr>
          <th width="5">
            <?php echo JText::_( 'NUM' ); ?>
          </th>        
          <th width="20">
          </th>
          <th nowrap="nowrap">
            <?php echo JHTML::_('grid.sort',   'Title', 'm.title', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
          </th>
          <th nowrap="nowrap">
            <?php echo JHTML::_('grid.sort',   'Code', 'm.code', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
          </th>
          <th nowrap="nowrap">
            <?php echo JHTML::_('grid.sort',   'User', 'm.user', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
          </th>
          <th nowrap="nowrap">
            <?php echo JHTML::_('grid.sort',   'Email', 'm.email', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
          </th>
          <th nowrap="nowrap">
            <?php echo JHTML::_('grid.sort',   'Url', 'm.url', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
          </th>
          <th nowrap="nowrap">
            <?php echo JHTML::_('grid.sort',   'Comment', 'm.comment', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
          </th>
          <th nowrap="nowrap">
            <?php echo JHTML::_('grid.sort',   'Tags', 'm.tags', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
          </th>

        </tr>
      </thead>
      <tfoot>
        <tr>
          <td colspan="13">
            <?php echo $this->pagination->getListFooter(); ?>
          </td>
        </tr>
      </tfoot>
      <?php
      $evenodd = 0;
      for ($i = 0, $n = count($this->items); $i < $n; $i += 1)
      {
        $row = $this->items[$i];
        $link = JRoute::_( 'index.php?option=com_wbdatabase&controller=wbdatabase&task=edit&cid[]='. $row->id );
        //$checked  = JHTML::_('grid.checkedout',   $row, $i );
        $checked    = JHTML::_( 'grid.id', $i, $row->id );
        //$published  = JHTML::_('grid.published', $row, $i );
        
        
        $url = $row->url;
        $ur1 = $url;
        $ur2 = strpos($url, 'http://');
        if ($url !== '')
        {
          $ur3 = 'A-niet';
        }
        else
        {
          $ur3 = 'A-leeg';
        }
        if ($url != '')
        {
          $ur4 = 'B-niet';
        }
        else
        {
          $ur4 = 'B-leeg';
        }
        if (($url != '') and
            (strpos($url, 'http://') !== 0) and
            (strpos($url, 'file://') !== 0) and
            (strpos($url, 'svn://') !== 0) and
            (strpos($url, 'ftp://') !== 0)
            )
        {
          $url = 'http://' . $url;
        }
        
                
            
        
      ?>
      <tr class="<?php echo "row$evenodd"; ?>">
        <td>
          <?php echo $this->pagination->getRowOffset( $i ); ?>
        </td>
        <td>
          <?php echo $checked; ?>
        </td>
        <td>
          <span class="editlinktip hasTip" title="<?php echo JText::_( 'Edit Record' );?>::<?php echo $row->title; ?>">
            <a href="<?php echo $link  ?>">
              <?php echo $row->title; ?>
            </a>
          </span>
        </td>
        <td>
          <?php echo $row->code;?>
        </td>
        <td>
          <?php echo $row->user;?>
        </td>
        <td>
          <?php echo $row->email;?>
        </td>
        <td>
          <?php if ($url == '')
          {
            echo $row->url;
          }
          else
          {?>
          <a href="<?php echo $url; ?>" target="_blank">
            <?php echo $row->url;?>
          </a>
          <?php 
          }
          ?>    
        </td>
        <td>
          <?php echo $row->comment;?>
        </td>
        <td>
          <?php echo $row->tags;?>
        </td>
      </tr>
      <?php
          $evenodd = 1 - $evenodd;
        }
      ?>
    </table>
  </div>
  
  <input type="hidden" name="option" value="com_wbdatabase" />
  <input type="hidden" name="task" value="" />
  <input type="hidden" name="boxchecked" value="0" />
  <input type="hidden" name="controller" value="wbdatabase" />
  <input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
  <input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />
  <?php echo JHTML::_( 'form.token' ); ?>
  
</form>

